package com.jinyu.jyly.adapter;

import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jinyu.jyly.R;
import com.jinyu.jyly.bean.ChoiceAddressListInfo;

import java.util.List;


/**
 * 获取城市
 */
public class ChangeTwoAdapter extends BaseQuickAdapter<ChoiceAddressListInfo.CityBean, BaseViewHolder> {

    private int position;
    public ChangeTwoAdapter(List<ChoiceAddressListInfo.CityBean> data, int layoutResIds) {
        super(layoutResIds, data);
    }

    /**
     * 改变view
     */
    public void setSelectItem(int position) {
        this.position = position;
    }
    @Override
    protected void convert(final BaseViewHolder helper, final ChoiceAddressListInfo.CityBean item) {
        helper.setText(R.id.tv_content,item.getName());

        TextView tv_content = helper.getView(R.id.tv_content);
        int adapterPosition = helper.getAdapterPosition();

        tv_content.setBackgroundColor(mContext.getResources().getColor(R.color.white));
        tv_content.setTextColor(mContext.getResources().getColor(R.color.black_01));
        if(position == adapterPosition){
            tv_content.setBackgroundColor(mContext.getResources().getColor(R.color.white01));
            tv_content.setTextColor(mContext.getResources().getColor(R.color.blue01));
        }
    }

}


